package com.runfast.waimai.web.controller.Driver_controller;

import com.runfast.paotui.dao.model.RunfastShopper;
import com.runfast.paotui.service.RunfastShopperService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
/**
 * ${DESCRIPTION} 骑手
 *
 * @author mengxiang
 * @create 2018-05-29  12:27
 **/
@Controller
@RequestMapping("/shopper/*")
public class DriverMsgController {
    @Resource
    RunfastShopperService shopperService;
    @PostMapping("add") //添加骑手信息，中增加了全职 身份证号
    public @ResponseBody ModelMap add(RunfastShopper shopper){
        ModelMap model=new ModelMap();
        if(shopper!=null){
            shopperService.insertSelective(shopper);
            model.put("success",true);
        } else {
            model.put("msg","添加失败");
        }


        return  model;
    }
    @PostMapping("update1") //更新骑手的状态
    public @ResponseBody ModelMap update1(RunfastShopper shopper){
        ModelMap model=new ModelMap();
        if(shopper!=null){
            shopperService.update(shopper);
            model.put("success","骑手状态已修改");
        }else {
            model.put("msg","更新失败");
        }
        return model;
    }
    @PostMapping("findmax") //多项条件 查询骑手 上班查询 ，代理查询，全职兼职查询， 姓名模糊查询（姓名 可以是一个字，但不能为空，其它查询条件可以为空）
    public @ResponseBody ModelMap findmax(
            Integer working, Integer work_Type, Integer gentid ,String name
    ){
        ModelMap model=new ModelMap();
//        working=1;
//        work_Type=1;
//        gentid=1;
        String name1="%"+name+"%";
         List<RunfastShopper> runfastShopperList=shopperService.findAgentidAndWordtypeAndWorkingAndName(gentid,work_Type,working,name1);
         if(runfastShopperList==null){
             model.put("msg","没有你输入的条件的结果 ");
         }
         model.put("list",runfastShopperList);
        return model;
    }
}
